//
//  JFButton.m
//  JFFootball
//
//  Created by 张志峰 on 2016/11/21.
//  Copyright © 2016年 zhifenx. All rights reserved.
//

#import "JFButton.h"

@interface JFButton ()

@property (nonatomic, strong) UILabel *jfLabel;
@property (nonatomic, strong) UIImageView *jfImageView;

@end

@implementation JFButton

- (void)setTitle:(NSString *)title {
    self.jfLabel.text = title;
}

- (void)setTitleColor:(UIColor *)titleColor {
    self.jfLabel.textColor = titleColor;
}

- (void)setImageName:(NSString *)imageName {
    self.jfImageView.image = [UIImage imageNamed:imageName];
}

- (UILabel *)jfLabel{
    if (!_jfLabel) {
        self.jfLabel = [[UILabel alloc] init];
        _jfLabel.textAlignment = NSTextAlignmentCenter;
        _jfLabel.font = [UIFont systemFontOfSize:14];
        [self addSubview:_jfLabel];
    }
    return _jfLabel;
}

- (UIImageView *)jfImageView{
    if (!_jfImageView) {
        self.jfImageView = [[UIImageView alloc] init];
        [self addSubview:_jfImageView];
    }
    return _jfImageView;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.jfLabel.frame = CGRectMake(0, 0, self.frame.size.width - 10, self.frame.size.height);
    self.jfImageView.size = CGSizeMake(7, 5);
    self.jfImageView.right = self.width - 5;
    self.jfImageView.centerY = self.height / 2.0;
}

@end
